<?php
/**
 * Created by PhpStorm.
 * User: boye009
 * Date: 2016/3/22
 * Time: 9:51
 */

namespace Api\Domain;


use Shop\Api\FavoritesApi;

class FavoritesDomain extends BaseDomain{

    protected $business_code = "favorites";

    protected $allowType = array("json", "rss", "html");


    public function cancel(){

        $notes = "应用".$this->client_id."，调用批量取消收藏接口";
        addLog("Favorites/cancel",$_GET,$_POST,$notes);

        $favorite_id = $this -> _post('favorite_id',-1,'id参数缺失');
        $type = $this -> _post('type',0,'缺少type参数');

        $favorite_id = explode(',',$favorite_id);

        $success_id = "";

        foreach($favorite_id as $k => $v){

            $map = array(
                'favorite_id' => $v,
                'type' => $type,
            );

            $result = apiCall(FavoritesApi::DELETE,array($map));
            if($result['status']){
                $success_id = $success_id.$v.",";
            }else{
                $this -> apiReturnErr("未完全删除成功!".$result['info'].'..已删除成功'.$success_id);
            }

        }
        $this -> apiReturnSuc("删除成功!");


    }

}